import { createRouter, createWebHashHistory } from 'vue-router'
/* Router Modules */
import Layout from '@/layout/index.vue'
import { i18n } from '@/lang'
const { t, te } = i18n.global

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    hidden: true
  },
  {
    path: '/register',
    component: () => import('@/views/login/register.vue'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404.vue'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401.vue'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: 'index',
        name: 'HomePage',
        component: () => import('@/views/dashboard/index.vue'),
        meta: { title: 'router.dashboard', elSvgIcon: 'Fold', affix: true }
      }
    ]
  },
  {
    path: '/oss',
    component: Layout,
    alwaysShow: true,
    meta: { title: 'router.modelManage', icon: 'example' },
    children: [
      {
        path: 'oss/index',
        name: 'uploadModelManage',
        component: () => import('@/views/system/oss/index.vue'),
        meta: { title: 'router.uploadManage', icon: 'Fold' }
      },
      {
        path: 'oss/downModel',
        name: 'downloadModelManage',
        component: () => import('@/views/system/oss/downModel.vue'),
        meta: { title: 'router.downloadManage', icon: 'Fold' }
      },
      {
        path: 'oss/3DPredict',
        name: 'predictModelManage',
        component: () => import('@/views/system/oss/ModelPredict.vue'),
        meta: { title: 'router.predictManage', icon: 'Fold' }
      }, 
      {
        path: 'oss/modelConvert',
        name: 'convertModelManage',
        component: () => import('@/views/system/oss/modelConvert.vue'),
        meta: { title: 'router.convertManage', icon: 'Fold' },
      }
    ]
  },
  {
    path: '/system',
    component: Layout,
    alwaysShow: true,
    meta: { title: 'router.systemManage', icon: 'example' },
    children: [
      {
        path: '/user/inde',
        component: () => import('@/views/system/user/index.vue'),
        name: 'UserManage',
        meta: { title: 'router.userManage', icon: 'Fold'}
      },
      {
        path: '/setting/index',
        component: () => import('@/views/setting/index.vue'),
        name: 'setting',
        meta: { title: 'router.admineSetting', icon: 'Fold' }
      },
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = []
export const noMathPage = { path: '/:pathMatch(.*)', redirect: '/404', hidden: true }
const router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior: () => ({ top: 0 }),
  routes: constantRoutes
})

export default router
